package com.farm.factory;

import com.farm.AgriculturalMachine;

// 工厂方法模式使用示例
public class FactoryMethodDemo {
    public static void main(String[] args) {
        String  machineName = "农机";
        MachineFactory seedingFactory = new SeedingMachineFactory();
        AgriculturalMachine seeder = seedingFactory.createMachine();
        seeder.operate(machineName);
        seeder.displayStatus(machineName);

        MachineFactory sprayingFactory = new SprayingMachineFactory();
        AgriculturalMachine sprayer = sprayingFactory.createMachine();
        sprayer.operate(machineName);
        sprayer.displayStatus(machineName);

        MachineFactory havingFactory = new HarvestingMachineFactory();
        AgriculturalMachine harvester = havingFactory.createMachine();
        harvester.operate(machineName);
        harvester.displayStatus(machineName);
    }
}
